local packer = require("packer")
local sharePath = require("commConf").sharePath

packer.startup({
	function(use)
		-- Packer 可以管理自己本身
		use 'wbthomason/packer.nvim'
		-- 插件列表...
		use 'elianiva/gruvy.nvim'
		use 'RRethy/nvim-base16'

		use {
			'kyazdani42/nvim-tree.lua',
			requires = {
				'kyazdani42/nvim-web-devicons', -- optional, for file icons
			},
			tag = 'nightly' -- optional, updated every week. (see issue #1193)
		}

		use {
			"akinsho/bufferline.nvim",
			requires = {
				"kyazdani42/nvim-web-devicons",
				"moll/vim-bbye"
			}
		}

		use {
			"nvim-lualine/lualine.nvim",
			requires = {
				"kyazdani42/nvim-web-devicons"
			}
		}
		use "arkav/lualine-lsp-progress"

		use {
			'nvim-telescope/telescope.nvim',
			requires = {
				"nvim-lua/plenary.nvim"
			}
		}

		-- telescope extensions
		use "LinArcX/telescope-env.nvim"

		use ({
			"nvim-treesitter/nvim-treesitter",
			run = function()
				local ts_update = require("nvim-treesitter.install").update({ with_sync = true })
				ts_update()
			end,
			requires = {
				{ "p00f/nvim-ts-rainbow" },
				{ "windwp/nvim-ts-autotag" },
				{ "nvim-treesitter/nvim-treesitter-refactor" },
			},
			config = function()
				require("plugin-config.nvim-treesitter")
			end,
		})
		--------------------- LSP --------------------
		-- Lspconfig
		use {
			"neovim/nvim-lspconfig",
		}
		use {
			"williamboman/mason.nvim",
			"williamboman/mason-lspconfig.nvim",
		}

	end,
	config = {
		-- 并发数限制
		max_jobs = 16,
		-- 浮动窗口打开安装列表
		display = {
			open_fn = function()
				return require("packer.util").float({ border = "single" })
			end,
		},
	},
})


-- 每次保存 plugins.lua 自动安装插件
pcall(
	vim.cmd,
		[[
			augroup packer_user_config
			autocmd!
			autocmd BufWritePost plugins.lua source <afile> | PackerSync
			augroup end
		]]
)

